package io.github.frailty9.crserver.model

import java.time.LocalDateTime
import com.mybatisflex.annotation.Column
import com.mybatisflex.annotation.Id

/**
 * 资源实例表（可预约单元）
 */
data class ResourceInstance(
    @Id
    override var id: Long? = null,
    /**
     * 关联 resource.id
     */
    var resourceId: Long? = null,
    /**
     * 开始时间
     */
    var startTime: LocalDateTime? = null,
    /**
     * 结束时间
     */
    var endTime: LocalDateTime? = null,
    /**
     * 预约开放时刻
     */
    var startBookableTime: LocalDateTime? = null,
    /**
     * 可预约结束时刻
     */
    var endBookableTime: LocalDateTime? = null,
    /**
     * 该实例最大可预约单位数
     */
    var capacityUnits: Int? = null,
    /**
     * 剩余可约单位
     */
    var remainingUnits: Int? = null,
    /**
     * 1=可预约, 0=已满
     */
    var status: Int? = null,

    @Column(version = true)
    override var version: Int? = null,

    @Column(onInsertValue = "CURRENT_TIMESTAMP")
    var createTime: LocalDateTime? = null,

    @Column(onInsertValue = "CURRENT_TIMESTAMP", onUpdateValue = "CURRENT_TIMESTAMP")
    var updateTime: LocalDateTime? = null,

    @Column(isLogicDelete = true)
    override var deleted: Int? = null
) : BaseModel
